home *** CD-ROM | disk | FTP | other *** search
/ Violence in 3D (Black Bird Entertainment) / Violence in 3D.iso / darkf / utils / gobber / make_gob.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-19  |  2.2 KB  |  83 lines

  1. Program Make_Dark_Forces_GOB;
  2. type
  3.   dirblock               = record
  4.                              Offset, len : longint;
  5.                              filename    : array[1..13] of byte;
  6.                            end;
  7.  
  8. var
  9.  dirblocks               : array[1..1024] of dirblock;
  10.  file1, file2            : file;
  11.  buffer                  : array[0..32767] of byte;
  12.  infile, outfile,lstfile : string;
  13.  i                       : integer;
  14.  directory               : text;
  15.  cnt, dirbegin           : longint;
  16.  result, direntry        : word;
  17.  b                       : array[1..13] of byte;
  18.  
  19. begin
  20.   if paramcount < 1 then
  21.   begin
  22.     writeLn('Usage:   MAKE_GOB  gobfile');
  23.     halt;
  24.   end;
  25.   infile := paramstr(1);
  26.   for i := 1 to length(infile) do
  27.     infile[i] := upcase(infile[i]);
  28.   if pos('.GOB', infile) = 0 then
  29.   begin
  30.     lstfile := infile + '.LST';
  31.     infile := infile + '.GOB';
  32.   end
  33.   else
  34.   begin
  35.     lstfile := copy(infile, 1, length(infile) - 4) + '.LST';
  36.   end;
  37.   assign(file1, infile);
  38.   rewrite(file1,1);
  39.   b[1] := 71;
  40.   b[2] := 79;
  41.   b[3] := 66;
  42.   b[4] := 10;
  43.   blockwrite(file1,b,4,result);
  44.   dirbegin := 0;
  45.   blockwrite(file1,dirbegin,4,result);
  46.   direntry := 0;
  47.   assign(directory,lstfile);
  48.   reset(directory);
  49.   cnt := 0;
  50.   while not eof (directory) do
  51.   begin
  52.     readln(directory,outfile);
  53.     writeln(outfile);
  54.     assign(file2, outfile);
  55.     reset(file2, 1);
  56.     inc(direntry);
  57.     dirblocks[direntry].Offset := filepos(file1);
  58.     dirblocks[direntry].len := filesize(file2);
  59.     for i := 1 to 13 do
  60.       if i <= length(outfile) then
  61.         dirblocks[direntry].filename[i] := ord(outfile[i])
  62.       else
  63.         dirblocks[direntry].filename[i] := 0;
  64.     inc(cnt);
  65.     while not eof(file2) do
  66.     begin
  67.       blockread(file2, buffer, 32768, result);
  68.       blockwrite(file1, buffer, result, result);
  69.     end;
  70.     close(file2);
  71.   end;
  72.   dirbegin := filepos(file1);
  73.   blockwrite(file1,cnt,4,result);
  74.   seek(file1,4);
  75.   blockwrite(file1,dirbegin,4,result);
  76.   seek(file1,dirbegin+4);
  77.   for direntry := 1 to cnt do
  78.     blockwrite(file1,dirblocks[direntry],21,result);
  79.   close(file1);
  80.   close(directory);
  81. end.
  82.  
  83.